package com.glls.sbdemo7.controller;

import com.glls.sbdemo7.pojo.Blogger;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.ArrayList;
import java.util.List;

/**
 * @date 2023/5/16
 * @desc
 */
@Controller
@RequestMapping("/thy")
public class ThyController {

    @RequestMapping("/index")
    public String index(){


        return "index";
    }


    @RequestMapping("/blogger")
    public String blogger(Model model){

        Blogger blogger = new Blogger(1L, "zs", "123");
        model.addAttribute("blogger",blogger);
        return "blog/blogger";
    }


    @GetMapping("/getList")
    public String getList(Model model) {
        Blogger blogger1 = new Blogger(1L, "zs", "123456");
        Blogger blogger2 = new Blogger(2L, "ls", "123456");
        List<Blogger> list = new ArrayList<>();
        list.add(blogger1);
        list.add(blogger2);
        model.addAttribute("list", list);
        return "blog/list";
    }

}
